import {
  q as n,
  p as M,
  ap as R,
  X as v,
  f as A,
  H as N,
  av as y,
  aw as O,
  az as T,
  as as s,
  aG as V,
  at as g
} from "./index-b50e6ef9.js";
import { f as b } from "./finance-81050a55.js";
function j(x) {
  const c = n([]),
    a = n(!0);
  n({}), M();
  const f = n(1),
    u = n(10),
    m = n({}),
    w = R("reload"),
    d = v({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    B = v({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    C = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      { label: "金额", prop: "money", minWidth: 80 },
      {
        label: "支付方式",
        prop: "pay_type",
        minWidth: 80,
        formatter: ({ pay_type: e }) => {
          if (e == 1) return "微信";
          if (e == 2) return "支付宝";
          if (e == 4) return "复消积分";
        }
      },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    S = A(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    T(e);
  }
  async function W(e) {
    const o = { role_id: e.role_id },
      r = JSON.stringify(o),
      i = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(r)) },
      t = await V(i);
    t.code == 200
      ? (g("删除成功", { type: "success" }), w())
      : g(t.msg, { type: "error" });
  }
  function J() {}
  function _(e) {
    (u.value = e), p(void 0, e);
  }
  function z(e) {
    (f.value = e), p(e, void 0);
  }
  function U(e) {}
  function k(e) {
    (B.text = `正在加载第${e}页...`),
      (a.value = !0),
      y(600).then(() => {
        a.value = !1;
      });
  }
  async function D(e) {
    (a.value = !0), (m.value = e);
    const o = {
        page: 1,
        pagesize: u.value,
        content: "recharge",
        user_phone: e.user_phone,
        type: e.type
      },
      r = JSON.stringify(o),
      i = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(r)) },
      { data: t } = await b(i);
    (c.value = t.recharge.data),
      (d.total = t.recharge.total),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function p(e = f.value, o = u.value) {
    const r = { page: e, pagesize: o, content: "recharge", type: m.value.type },
      h = JSON.stringify(r),
      t = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(h)) },
      l = await b(t);
    l.code === 200
      ? ((c.value = l.data.recharge.data),
        (d.total = l.data.recharge.total),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : g(l.msg, { type: "error" });
  }
  const L = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    N(() => {
      y().then(() => {
        const { setWatermark: e } = O(x.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        p();
    }),
    {
      loading: a,
      columns: C,
      dataList: c,
      pagination: d,
      buttonClass: S,
      onSearch: D,
      resetForm: L,
      handleaddUser: J,
      handleUpdate: I,
      handleDelete: W,
      handleSizeChange: _,
      handleCurrentChange: z,
      handleSelectionChange: U,
      onCurrentChange: k
    }
  );
}
export { j as useRole };
